#ifndef IO_H
#define IO_H


#define WRITE( addr, data ) *( (volatile unsigned int *) ( addr ) ) = data
#define READ( addr )  *( (volatile unsigned int *) ( addr ) )

#define read_mreg32(addr) (*(volatile unsigned int *)(addr))
#define write_mreg32(addr,val) *(volatile unsigned int *)(addr) = (u32)(val)

#define read_mreg16(addr) (*(volatile unsigned short *)(addr))
#define write_mreg16(addr,val) *(volatile unsigned short *)(addr) = (u16)(val)

#define read_mreg8(addr) (*(volatile unsigned char *)(addr))
#define write_mreg8(addr,val) *(volatile unsigned char*)(addr) = (u8)(val)

#define readl(addr)				(*(volatile unsigned int *)(addr))
#define writel(val, addr)		(*(volatile unsigned int *)(addr) = (val))

#define readw(addr)				(*(volatile unsigned short *)(addr))
#define writew(val, addr)		(*(volatile unsigned short *)(addr) = (val))

#define readb(addr)				(*(volatile unsigned char *)(addr))
#define writeb(val, addr)		(*(volatile unsigned char *)(addr) = (val))

// --------------------------------------------------------------------
//	waiting to remove
// --------------------------------------------------------------------
#define ioread32(p)				(*(volatile unsigned int *)(p))
#define iowrite32(v, p)			(*(volatile unsigned int *)(p) = (v))

#define inl(p)					ioread32(p)
#define outl(v, p)				iowrite32(v, p)

#define inw(port)				readl(port)
#define outw(port, val)			writel(val, port)

#define inb(port)				readb(port)
#define outb(port, val)			writeb(val, port)

#define inhw(port)				readw(port)
#define outhw(port, val)		writew(val, port)

#define REG8  (volatile unsigned char*)
#define REG16 (volatile unsigned short*)
#define REG32 (volatile unsigned int*)


#endif // IO_H
